<?php

class m110920_010712_project_base extends CDbMigration {
	public function safeUp() {
		$this
			->createTable('erp_project',
				array(
					'id' => 'pk',
					'name' => 'string',
					'note' => 'string',
					'createTime' => 'datetime',
					'createUserId' => 'int',
					'updateTime' => 'datetime',
					'updateUserId' => 'int',
				));
		$this->createIndex("project_create_user_id", 'erp_project', 'createUserId');
		$this
			->addForeignKey('fk_project_create_user_id', 'erp_project', 'createUserId', 'erp_user',
				'id', 'SET NULL', 'CASCADE');
		$this->createIndex("project_update_user_id", 'erp_project', 'updateUserId');
		$this
			->addForeignKey('fk_project_update_user_id', 'erp_project', 'updateUserId', 'erp_user',
				'id', 'SET NULL', 'CASCADE');
	}

	public function safeDown() {
		$this->dropTable('erp_project');
	}
}
